﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  
  <xs:element name="LateBindingApi.CodeGenerator.Document">
    <xs:complexType>
    <xs:sequence>
      <xs:element name="Components" type="Components" />
      <xs:element name="Externals" type="Externals" />
      <xs:element name="Solution" type="Solution" />
    </xs:sequence>
    </xs:complexType>
  </xs:element>
  
  <xs:complexType name="RefComponents">
    <xs:sequence>
      <xs:element name="RefComponent" type="RefComponent" minOccurs ="0" maxOccurs ="unbounded"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="RefComponent">
    <xs:attribute name="Key" type="xs:string" use="required" /> <!-- component key or external key -->
  </xs:complexType>
  
  <xs:complexType name="Components">
    <xs:sequence>
      <xs:element name="Component" type="Component" minOccurs ="0" maxOccurs ="unbounded"/>
    </xs:sequence>
  </xs:complexType>
  
  <xs:complexType name="Component">
    <xs:sequence>
      <xs:element name="Name"           type="xs:string" />             <!-- Component Name -->
      <xs:element name="ContainingFile" type="xs:string"/>              <!-- Assembly Path -->
      <xs:element name="Key"            type="xs:string" />             <!-- Generated unique Key for the Component -->
      <xs:element name="GUID"           type="xs:string" />             <!-- Component GUID -->
      <xs:element name="HelpFile"       type="xs:string"/>              <!-- Helpfile Path -->
      <xs:element name="MajorVersion"   type="xs:unsignedByte" />       <!-- TypeLib MajorVersion -->
      <xs:element name="MinorVersion"   type="xs:unsignedByte" />       <!-- TypeLib MinorVersion -->
      <xs:element name="LCID"           type="xs:unsignedByte" />       <!-- TypeLib LCID -->
      <xs:element name="Description"    type="xs:string" />             <!-- Description of TypeLib -->
      <xs:element name="Version"        type="xs:string" />             <!-- SupportByLibrary Value -->
      <xs:element name="SysKind"        type="xs:unsignedByte" />       <!-- WIN16 WIN32 or Mac -->
    </xs:sequence>
  </xs:complexType>
  
  <xs:complexType name="Externals">
    <xs:sequence>
      <xs:element name="External"   type="External"  minOccurs ="0" maxOccurs ="unbounded"/>
    </xs:sequence>
  </xs:complexType>
  
  <xs:complexType name="External">
    <xs:sequence>
      <xs:element name="ExternalComponent" type="ExternalComponent"  minOccurs ="0" maxOccurs ="unbounded"/>
    </xs:sequence>
    <xs:attribute name="Name"       type="xs:string" use="required" />  <!-- Name of the external -->
    <xs:attribute name="Prefix"     type="xs:string" use="required" />  <!-- Class Prefix -->
    <xs:attribute name="Namespace"  type="xs:string" use="required" />  <!-- Namespace -->
    <xs:attribute name="Key"        type="xs:string" use="required" />  <!-- Generated unique Key for the External -->
  </xs:complexType>
  
  <xs:complexType name="ExternalComponent">
    <xs:sequence>
      <xs:element name="Key"          type="xs:string" />               <!-- Generated unique Key for the ExternalComponent -->
      <xs:element name="GUID"         type="xs:string" />               <!-- Component GUID-->
      <xs:element name="HelpFile"     type="xs:string"/>                <!-- Helpfile Path -->
      <xs:element name="MajorVersion" type="xs:unsignedByte" />         <!-- TypeLib MajorVersion -->
      <xs:element name="MinorVersion" type="xs:unsignedByte" />         <!-- TypeLib MinorVersion -->
      <xs:element name="LCID"         type="xs:unsignedByte" />         <!-- TypeLib LCID -->
      <xs:element name="Description"  type="xs:string" />               <!-- Description of TypeLib -->
      <xs:element name="SysKind"      type="xs:unsignedByte" />         <!-- WIN16 WIN32 or Mac -->
    </xs:sequence>
  </xs:complexType>
  
  <xs:complexType name="Solution">
      <xs:sequence>
        <xs:element name="Projects" type="Projects" />
      </xs:sequence>
  </xs:complexType>
  
  <xs:complexType name="Projects">
      <xs:sequence>
        <xs:element name="Project" type="Project" minOccurs ="0" maxOccurs ="unbounded"/>
      </xs:sequence>
  </xs:complexType>
  
  <xs:complexType name="Project">
    <xs:sequence>
      <xs:element name="Enums"              type="Enums"/>
      <xs:element name="CoClasses"          type="CoClasses"/>
      <xs:element name="DispatchInterfaces" type="DispatchInterfaces"/>
      <xs:element name="EventInterfaces"    type="EventInterfaces"/>
    </xs:sequence>
    <xs:attribute name="Name"        type="xs:string" use="required" />   <!-- name of project -->
    <xs:attribute name="ProjectName" type="xs:string" use="required" />   <!-- name of project.csharp -->
    <xs:attribute name="Namespace"   type="xs:string" use="required" />   <!-- namespace of project -->
  </xs:complexType>

  <xs:complexType name="DispatchInterfaces">
    <xs:sequence>
      <xs:element name="DispatchInterface" type="DispatchInterface" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="DispatchInterface">
    <xs:sequence>
      <xs:element name="Name"           type="xs:string"  /> <!-- interface name -->
      <xs:element name="EventInterface" type="xs:string" />
      <xs:element name="Properties"     type="Properties" />
      <xs:element name="Methods"        type="Methods" />
      <xs:element name="RefComponents"  type="RefComponents" />
    </xs:sequence>
  </xs:complexType>
  
  <xs:complexType name="CoClasses">
    <xs:sequence>
      <xs:element name="CoClass" type="CoClass" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>
  
  <xs:complexType name="CoClass">
    <xs:sequence>
      <xs:element name="Name"           type="xs:string"  /> <!-- class name -->
      <xs:element name="Properties"     type="Properties" />
      <xs:element name="Methods"        type="Methods" />
      <xs:element name="EventInterface" type="EventInterface" />
      <xs:element name="RefComponents"  type="RefComponents" />
    </xs:sequence>
  </xs:complexType>
  
  <xs:complexType name="EventInterfaces">
    <xs:sequence>
      <xs:element name="EventInterface" type="EventInterface" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>
  
  <xs:complexType name="EventInterface">
    <xs:sequence>
      <xs:element name="Name"          type="xs:string"  />   <!-- interface name -->
      <xs:element name="GUID"          type="xs:string"  />   <!-- interface guid -->
      <xs:element name="Methods"       type="Methods" />
      <xs:element name="RefComponents" type="RefComponents" />
    </xs:sequence>
  </xs:complexType>
  
  <xs:complexType name="DispIds">
    <xs:sequence>
      <xs:element name="DispId" type="DispId" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="DispId">
    <xs:attribute name="Id" type="xs:integer" use="required" />  <!-- component key or external key -->
    <xs:attribute name="Key" type="xs:integer" use="required" /> <!-- component key or external key -->
  </xs:complexType>
  
  <xs:complexType name="Enums">
    <xs:sequence>
      <xs:element name="Enum" type="Enum" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="Enum">
    <xs:sequence>
      <xs:element name="Name"          type="xs:string"  />     <!-- enum name -->
      <xs:element name="EnumMembers"   type="EnumMembers" />
      <xs:element name="RefComponents" type="RefComponents" />
    </xs:sequence>
  </xs:complexType>
  
  <xs:complexType name="EnumMembers">
    <xs:sequence>
      <xs:element name="EnumMember" type="EnumMember" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="EnumMember">
    <xs:sequence>
      <xs:element name="Name"          type="xs:string"  /> <!-- member name -->
      <xs:element name="Value"         type="xs:integer"  /> <!-- member value -->
      <xs:element name="RefComponents" type="RefComponents" />
    </xs:sequence>
  </xs:complexType>
  
  <xs:complexType name="Property">
      <xs:sequence>
      <xs:element name="IsComProxy" type="xs:boolean" />  <!-- property is a com object -->
      <xs:element name="IsExternal" type="xs:boolean" />  <!-- property type is defined in external library-->
      <xs:element name="IsArray"    type="xs:boolean" />  <!-- property is an array -->
      <xs:element name="Name"       type="xs:string"  />  <!-- property name -->
      <xs:element name="Type"       type="xs:string"  />  <!-- property type -->
      <xs:element name="TypeKind"   type="xs:string"  />  <!-- property typekind -->
      <xs:element name="InvokeKind" type="xs:string"  />  <!-- GET PUT or PUTREF -->
      <xs:element name="Key"        type="xs:string"  />  <!-- project key or external key there is the param type defined -->
      <xs:element name="Parameters" type="Parameters" />
      <xs:element name="RefComponents" type="RefComponents" />
      </xs:sequence>
  </xs:complexType>
  
  <xs:complexType name="Properties">
    <xs:sequence>
       <xs:element name="Property" type="Property" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>
  
  <xs:complexType name="Method">
    <xs:sequence>
      <xs:element name="Name"           type="xs:string"  />        <!-- method name -->
      <xs:element name="HasReturnType"  type="xs:boolean" />        <!-- method have a return value -->
      <xs:element name="IsComProxy"     type="xs:boolean" />        <!-- return value is a com object -->
      <xs:element name="IsExternal"     type="xs:boolean" />        <!-- return value type is defined in external library-->
      <xs:element name="IsArray"        type="xs:boolean" />        <!-- return value is an array -->
      <xs:element name="Type"           type="xs:string"  />        <!-- return value type -->
      <xs:element name="TypeKind"       type="xs:string"  />        <!-- return value typekind -->
      <xs:element name="Key"            type="xs:string"  />        <!-- return value key or external key there is the param type defined -->
      <xs:element name="DispIds"        type="DispIds" />
      <xs:element name="Parameters"     type="Parameters" />
      <xs:element name="RefComponents"  type="RefComponents" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="Methods">
    <xs:sequence>
      <xs:element name="Method" type="Method" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>
  
  <xs:complexType name="Parameter">
    <xs:sequence>
      <xs:element name="IsComProxy" type="xs:boolean" />  <!-- param is a com object  -->
      <xs:element name="IsExternal" type="xs:boolean" />  <!-- param type is defined in external library -->
      <xs:element name="IsRef"      type="xs:boolean" />  <!-- param is given byRef -->
      <xs:element name="IsArray"    type="xs:boolean" />  <!-- param is an array -->
      <xs:element name="IsOptional" type="xs:boolean" />  <!-- param is an optional -->
      <xs:element name="Name"       type="xs:string"  />  <!-- param name -->
      <xs:element name="Type"       type="xs:string"  />  <!-- param type -->
      <xs:element name="TypeKind"   type="xs:string"  />  <!-- param typekind -->
      <xs:element name="Key"	      type="xs:string"  />  <!-- project key or external key there is the param type defined -->
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="Parameters">
      <xs:sequence>
        <xs:element name="Parameter" type="Parameter" minOccurs="0" maxOccurs="unbounded" />
      </xs:sequence>
  </xs:complexType>

</xs:schema>